﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using KegData;

namespace KegManager
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public static KegeratorDataContext OpenDataSource(String connectionString)
        {
            KegeratorDataContext monitor = new KegeratorDataContext(connectionString);
            
            if (!monitor.DatabaseExists())
            {
                MessageBoxResult result = MessageBox.Show("Database does not exist on the datasource.  Create it?", "Connection Error", MessageBoxButton.YesNo);

                if(result == MessageBoxResult.Yes)
                {
                    monitor.CreateDatabase();
                }
                else if(result == MessageBoxResult.No)
                {
                    // Exit?
                }
                
            }

            return monitor;
        }
    }
}
